
#include ".\mcpoint3d.h"

#include <math.h>

McPoint3D::McPoint3D(void)
{
}

McPoint3D::~McPoint3D(void)
{
}

McPoint3D::McPoint3D(double x1, double y1, double z1)
{
	x = x1;
	y = y1;
	z = z1;
}

McPoint3D::McPoint3D(const McPoint& p)
{
	x = p.X();
	y = p.Y();
	z = p.Z();
}


McPoint3D McPoint3D::operator+(const McPoint3D& p)
{
	McPoint3D newp(x+p.x,y+p.y,z+p.z);
	return newp;
}

McPoint3D McPoint3D::operator-(const McPoint3D& p)
{
	McPoint3D newp(x-p.x,y-p.y,z-p.z);
	return newp;
}

McPoint3D McPoint3D::operator*(const double scale)
{
	McPoint3D newp(x*scale,y*scale,z*scale);
	return newp;
}

McPoint3D& McPoint3D::operator=(const McPoint3D& p)
{
	if( this != &p)
	{
		x = p.x;
		y = p.y;
		z = p.z;
	}
	return *this;
}

bool McPoint3D::operator==(const McPoint3D& p)
{
	return ((p.x==x) && (p.y==y) && (p.z==z));
}

void McPoint3D::Scale(const double scale)
{
	x *= scale;
	y *= scale;
	z *= scale;
}

double McPoint3D::Distance(const McPoint& p) const
{
	double dx = x-p.X();
	double dy = y-p.Y();
	double dz = z-p.Z();
	double s = dx * dx + dy * dy + dz * dz;
	return (s<0 ? 0.0 :(double)sqrt(s));
}

double McPoint3D::Z() const
{
	return z;
}

double McPoint3D::GetZ() const
{
	return z;
}

double& McPoint3D::rZ()
{
	return z;
}

void McPoint3D::SetZ(const double z1)
{
	z = z1;
}

void McPoint3D::Set(const double x1, const double y1, const double z1)
{
	x = x1;
	y = y1;
	z = z1;
}

void McPoint3D::Get(double& x1, double& y1 , double& z1) const
{
	x1 = x;
	y1 = y;
	z1 = z;
}
